# -*- mode: snippet -*-
# name: csv: write csv from dictionary
# key: dictwriter@csv
# key: csv.dictwriter
# contributor: Shuguang Sun
# --
with open(${1:filename}, 'w') as csvfile:
    ${2:fieldnames} = $0
    writer = csv.DictWriter(csvfile, fieldnames = $2)

    writer.writeheader()
    writer.writerow(${3:dict})
